package com.optimatch.ui.controler.actions;

import java.awt.event.ActionEvent;

import com.optimatch.ui.controler.localization.Constants;
import com.optimatch.ui.controler.localization.LanguageManager;
import com.optimatch.ui.model.Model;
import com.optimatch.ui.view.View;
import com.optimatch.ui.view.customComponents.pages.FixerMatchDatePanel;

public class AddContrainteDateAction extends Action {

	public AddContrainteDateAction(Model model, View view, ListAction actions) {
		super(model, view, actions);
		putValue(Action.NAME, LanguageManager.getBundle()
				.getString(Constants.CREATE_CONSTRAINT_BUTTON));
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		FixerMatchDatePanel panel = view.getTabs().getContraintesPanel().getFixerDatePanel();
		int journee = panel.getListeChoixJournees().getSelectedIndex();
		int eq1 = panel.getEquipe1().getSelectedIndex();
		int eq2 = panel.getEquipe2().getSelectedIndex();
		boolean eq1ADomicile = panel.getEquipe1ADomicile().isSelected();
		
		model.fixerDateMatch(journee, eq1, eq2,eq1ADomicile);
	}

}
